package Object;


import java.util.Objects;

class Pearson{
    public String id ;

    @Override
    public boolean equals(Object obj) {
        //判断obj是否为null
        if(obj==null)return false;
        //判断obj是否和this引用的地址相同
        if(obj==this)return true;
        //判断obj是否为Pearson类型
        if(!(obj instanceof Pearson))return false;

        //为了访问id，所以向下转型了
        Pearson tmp=(Pearson) obj;
        return this.id.equals(tmp.id);
    }


    @Override
    public int hashCode() {
        return Objects.hash(id);
    }
}
public class Test {
    public static void main(String[] args) {
        Pearson pearson=new Pearson();
        pearson.id="wzj";
        Pearson pearson1=new Pearson();
        pearson1.id="wzj";
        System.out.println(pearson.hashCode());
        System.out.println(pearson1.hashCode());
    }
}
